<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge"/>
    <title>三个J-家居网购</title>
    <!-- 移动端适配 -->
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
    <link rel="stylesheet" href="/assets/css/vendor/vendor.min.css"/>
    <link rel="stylesheet" href="/assets/css/plugins/plugins.min.css"/>
    <link rel="stylesheet" href="/assets/css/style.min.css">

    <script type="text/javascript" src="/script/jquery-3.6.0.min.js">

    </script>
    <!--校验-->
    <script type="text/javascript">
        $(document).ready(function() {




            //绑定点击事件
            //alert("ok")
            $("#referBtn").click(function () {
              //  alert("ok")
                var add_price = $("#up_price").val();
                console.log(add_price)
                //编写正则表达式验证
                var pricePattern=/^([1-9][0-9]*)+(.[0-9]{1,2})?$/;
                if (!pricePattern.test(add_price)){
                    //展示错误提示
                    $("span[class='errorMsg']").text("价格格式不正确！请修改")
                    return false;//先不让提交
                }

                var add_sales = $("#up_sales").val();
                console.log(add_sales)
                var salesPattern=/^[1-9]\d*$/;
                if (!salesPattern.test(add_sales)){
                    $("span.errorMsg").text("销量格式不正确！请检查")
                    return  false;
                }
                var add_stock = $("#up_stock").val();
                console.log(add_stock)
                var stockPattern=/^[1-9]\d*$/;
                if (!stockPattern.test(add_stock)){
                    $("span.errorMsg").text("库存格式不正确！请检查")
                    return  false;
                }

                return  true;
            })

        })
    </script>
    <script>
        // 将 prev 函数定义在 head 标签内，确保它在全局作用域中可用
        function prev(inputElement) {
            // 获取展示图片的区域
            var img = document.getElementById("prevView");
            // 获取文件对象，注意这里应该是 inputElement.files 而不是 event.files
            var file = inputElement.files[0];
            if (file) {
                // 获取文件阅读器
                var reader = new FileReader();
                reader.onload = function(e) {
                    // 给 img 的 src 设置图片 url，使用 e.target.result 而不是 this.result
                    img.setAttribute("src", e.target.result);
                }
                // 读取文件内容
                reader.readAsDataURL(file);
            }
        }
    </script>
</head>

<body>
<!-- Header Area start  -->
<div class="header section">
    <!-- Header Top  End -->
    <!-- Header Bottom  Start -->
    <div class="header-bottom d-none d-lg-block">
        <div class="container position-relative">
            <div class="row align-self-center">
                <!-- Header Logo Start -->
                <div class="col-auto align-self-center">
                    <div class="header-logo">
                        <a href="index.html"><img src="/assets/images/logo/logo.png" alt="Site Logo"/></a>
                    </div>
                </div>
                <!-- Header Logo End -->

                <!-- Header Action Start -->
                <div class="col align-self-center">
                    <div class="header-actions">

                        <!-- Single Wedge Start -->
                        <div class="header-bottom-set dropdown">
                            <a href="#">家居管理</a>
                        </div>
                        <div class="header-bottom-set dropdown">
                            <a href="#">订单管理</a>
                        </div>
                    </div>
                </div>
                <!-- Header Action End -->
            </div>
        </div>
    </div>
    <!-- Header Bottom  End -->
    <!-- Header Bottom  Start 手机端的header -->
    <div class="header-bottom d-lg-none sticky-nav bg-white">
        <div class="container position-relative">
            <div class="row align-self-center">
                <!-- Header Logo Start -->
                <div class="col-auto align-self-center">
                    <div class="header-logo">
                        <a href="/member/index"><img width="280px" src="/assets/images/logo/logo.png" alt="Site Logo"/></a>
                    </div>
                </div>
                <!-- Header Logo End -->
            </div>
        </div>
    </div>
    <!-- Main Menu Start -->
    <div style="width: 100%;height: 50px;background-color: black"></div>
    <!-- Main Menu End -->
</div>
<!-- Cart Area Start -->
<div class="cart-main-area pt-100px pb-100px">
    <div class="container">
        <h3 class="cart-page-title">家居后台管理-修改家居</h3>
        <span class="errorMsg"></span>
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-12">
                <form action="/furn/updateFurn" method="post" enctype="multipart/form-data">
                    <div class="table-content table-responsive cart-table-content">
                        <table>
                            <thead>
                            <tr>
                                <th>图片</th>
                                <th>家居名</th>
                                <th>商家</th>
                                <th>价格</th>
                                <th>销量</th>
                                <th>库存</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td class="product-thumbnail">
                                    <div id="pic">
                                        <img  id="prevView" class="img-responsive ml-3"  th:src="${session.id_furn.imgPath}" src="#"
                                              alt=""/>
                                        <input type="file" name="imgPath1" th:value="${session.id_furn.imgPath}" onchange="prev(this)"/>

                                    </div>
                                </td>
                                <!--
                                -->
                                <td class="product-name" > <input th:value="${session.id_furn.getName()}" name="name" style="width: 60%" type="text" /></td>
                                <td class="product-name" ><input th:value="${session.id_furn.getMaker()}" name="maker" style="width: 90%" type="text" /></td>
                                <td class="product-price-cart" ><input id="up_price" th:value="${session.id_furn.getPrice()}" name="price" style="width: 90%" type="text"/></td>
                                <td class="product-quantity" >
                                    <input id="up_sales" th:value="${session.id_furn.getSales()}" name="sales" style="width: 90%" type="text" />
                                </td>
                                <td class="product-quantity" >
                                    <input id="up_stock" th:value="${session.id_furn.getStock()}"  name="stock" style="width: 90%" type="text" />
                                </td>
                                <td>
<!--                                    <a href="#"><i class="icon-pencil"></i></a>-->
<!--                                    <a href="#"><i class="icon-close"></i></a>-->
                                    <input id="referBtn"  type="submit" style="width: 90%;background-color: silver;border: silver;border-radius: 20%;" value="修改家居"/>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- Cart Area End -->

<!-- Footer Area Start -->
<div class="footer-area">
    <div class="footer-container">
        <div class="footer-top">
            <div class="container">
                <div class="row">
                    <!-- Start single blog -->
                    <!-- End single blog -->
                    <!-- Start single blog -->
                    <div class="col-md-6 col-sm-6 col-lg-3 mb-md-30px mb-lm-30px" data-aos="fade-up"
                         data-aos-delay="400">
                        <div class="single-wedge">
                            <h4 class="footer-herading">信息</h4>
                            <div class="footer-links">
                                <div class="footer-row">
                                    <ul class="align-items-center">
                                        <li class="li"><a class="single-link" href="about.html">关于我们</a></li>
                                        <li class="li"><a class="single-link" href="#">交货信息</a></li>
                                        <li class="li"><a class="single-link" href="privacy-policy.html">隐私与政策</a></li>
                                        <li class="li"><a class="single-link" href="#">条款和条件</a></li>
                                        <li class="li"><a class="single-link" href="#">制造</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- End single blog -->
                    <!-- Start single blog -->
                    <div class="col-md-6 col-lg-2 col-sm-6 mb-lm-30px" data-aos="fade-up" data-aos-delay="600">
                        <div class="single-wedge">
                            <h4 class="footer-herading">我的账号</h4>
                            <div class="footer-links">
                                <div class="footer-row">
                                    <ul class="align-items-center">
                                        <li class="li"><a class="single-link" href="my-account.html">我的账号</a>
                                        </li>
                                        <li class="li"><a class="single-link" href="cart.html">我的购物车</a></li>
                                        <li class="li"><a class="single-link" href="login.html">登录</a></li>
                                        <li class="li"><a class="single-link" href="wishlist.html">感兴趣的</a></li>
                                        <li class="li"><a class="single-link" href="checkout.html">结账</a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- End single blog -->
                    <!-- Start single blog -->
                    <div class="col-md-6 col-lg-3" data-aos="fade-up" data-aos-delay="800">

                    </div>
                    <!-- End single blog -->
                </div>
            </div>
        </div>
        <div class="footer-bottom">
            <div class="container">
                <div class="row flex-sm-row-reverse">
                    <div class="col-md-6 text-right">
                        <div class="payment-link">
                            <img src="#" alt="">
                        </div>
                    </div>
                    <div class="col-md-6 text-left">
                        <p class="copy-text">Copyright &copy; 2021 三个J~</p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- Footer Area End -->
<script src="/assets/js/vendor/vendor.min.js"></script>
<script src="/assets/js/plugins/plugins.min.js"></script>
<!-- Main Js -->
<script src="/assets/js/main.js"></script>
</body>
</html>